home *** CD-ROM | disk | FTP | other *** search
- (*****
- *
- * Test of generic sorting routine
- *
- *****)
- MODULE SortTest;
-
- FROM InOut IMPORT OpenInput, CloseInput, WriteString, WriteLn, ReadCard,
- OpenOutput, CloseOutput;
- FROM Sort IMPORT Qsort;
- FROM SortElemType IMPORT ElemType, select, optionMenu,
- ReadArray, WriteArray;
- CONST
- N = 200;
-
- VAR
- a : ARRAY [1..N] OF ElemType;
- n : CARDINAL; (* actual number of elements in "a" *)
- opt : CARDINAL;
-
- BEGIN
- WriteString("Which file contains the data ? ");
- OpenInput("");
- n:= ReadArray(a);
- CloseInput;
- optionMenu;
- WriteString("Sort by ? ");
- ReadCard(opt); WriteLn;
- select(opt);
- Qsort(a,n);
- WriteLn; WriteString("Output file [ Esc for console ] ? ");
- OpenOutput("");
- WriteArray(a,n);
- CloseOutput
- END SortTest.